import 'package:flutter/material.dart';

class GridViewWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: new Text("GridView"),
          leading: new BackButton(),
        ),
        body: Container(
          color: Colors.yellow,
          child: new GridView.count(
            //滚动的方向，有垂直和水平两种，默认为垂直方向（Axis.vertical）
            scrollDirection: Axis.vertical,
            //默认是从上或者左向下或者右滚动的，这个属性控制是否反向，默认值为false，不反向滚动
            reverse: false,
            //主轴间距
            mainAxisSpacing: 20,
            //交叉轴Item的个数
            crossAxisCount: 2,
            //交叉轴间距
            crossAxisSpacing: 10,
            padding: const EdgeInsets.only(top: 10),
            children: List.generate(100, (index) {
              return Container(
                  color: Colors.red,
                  child: Center(
                      child: Text(
                    "Item $index",
                    style: Theme.of(context).textTheme.displayLarge,
                  )));
            }),
          ),
        ));
  }
}
